/* ----------------------------------------------------------------------
 *	Shadow Quest
 *	Copyright (C) 2009 Prageeth Silva <prageeth@thenewcoders.com>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *  ----------------------------------------------------------------------
 */
package menu;

import java.util.ArrayList;

import menu.tabobject.MenuTabImage;
import menu.tabobject.MenuTabMultiline;
import menu.tabobject.MenuTabObject;

import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;

import sq.FileIO;
import sq.ImageLoader;
import sq.game.Quest;

/** A Menu Tab used in a SubMenu
 *
 */
public final class QuestTab extends MenuTab {

    private static final int IMAGE_X = 100;
    private static final int IMAGE_Y = 180;
    private static final int TEXT_X = 400;
    private static final int TEXT_Y = 180;

    private static final String DIR = "menu/";
    private static final String IMAGE_NAME = "image.png";
    private static final String TEXT_NAME = "text.txt";
    private Quest quest;

    /** Create a new MenuTab object
     * @param tabObjects a list of tab objects
     * @param title The title of the menu
     */
    public QuestTab(Quest quest)
            throws SlickException {

        super(new ArrayList<MenuTabObject>(), quest.getTitle());

        String p = quest.getDirectoryPath() + QuestTab.DIR;
        Image i = ImageLoader.getLoadedImage(p + QuestTab.IMAGE_NAME);
        MenuTabObject img = new MenuTabImage(i, QuestTab.IMAGE_X, QuestTab.IMAGE_Y);
        this.getTabObjects().add(img);

        MenuTabObject text = new MenuTabMultiline(FileIO.readTextFile(p + QuestTab.TEXT_NAME), QuestTab.TEXT_X, QuestTab.TEXT_Y);
        this.getTabObjects().add(text);

        this.setQuest(quest);

    }

    /**
     * @return the quest
     */
    public Quest getQuest() {
        return this.quest;
    }

    /**
     * @param quest the quest to set
     */
    private void setQuest(Quest quest) {
        this.quest = quest;
    }

}
